#!/bin/bash

>up.txt
>down.txt

for i in {1..254}
do
	
	(ping -c 1 -i 0.02 -w 1 192.168.0.${i} &>/dev/null
	if (($?==0))
	then
		echo "192.168.0.${i}" >>up.txt
		echo -e "\e[32m192.168.0.${i} is up \e[0m"
	else
		echo "192.168.0.${i}" >>down.txt
	
	fi)&
	
	sleep 0.01
done
sleep 1.5
b=`cat down.txt|wc -l` 
a=`cat up.txt|wc -l`
echo -e "\033[34m有用IP个数:$a \033[0m"
echo -e "\033[31m没有使用IP的个数:$b \033[0m"

